import { topCategory } from "@/api/constants";
import { getCategory } from "@/api/home";
// 商品分类vuex模块
export default {
    namespaced: true,
    state() {
        return {
            // 商品分类列表
            list: topCategory.map((item) => ({ name: item }))
        };
    },
    mutations: {
        StyleSheetList(state, payload) {
            state.list = payload
        }
    },
    actions: {
        // 获取分类列表
        async getList({ commit }) {
            const data = await getCategory();
            // data.result 即是分类列表
            commit("StyleSheetList", data.result);
        },
    },
};

